<template>
  <z-modal
    title="请填写原因"
    width="600px"
    v-bind="modalOption"
    :okText="false"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-form-model layout="horizontal" labelAlign="right" ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol" :model="form" :rules="validatorRules">
      <a-form-model-item label="原因" prop="$BPMN_COMMENT_">
        <a-textarea v-model="form.$BPMN_COMMENT_" />
      </a-form-model-item>
    </a-form-model>
  </z-modal>
</template>

<script>
import ModalMixins from '@/mixins/ModalMixins'
export default {
  name: 'CommentModal',
  mixins: [ModalMixins],
  data() {
    return {
      validatorRules: {
        $BPMN_COMMENT_: [{ required: true, message: '请填写原因' }]
      },
      form: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 17 }
      },
      task: {}
    }
  },
  methods: {
    show(task) {
      this.task = task
      this.visible = true
    },
    handleOk() {
      this.confirmLoading = true
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.$emit('ok', this.form)
          this.close()
        }
      })
    }
  }
}
</script>

